package com.tanhua.model.vo;

import com.tanhua.model.mongo.Report;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReportVo {

    private String conclusion;  // 鉴定结果
    private String cover;       // 鉴定图片

    private List<DimensionsVo> dimensions;     // 维度

    private List<SimilarYouVo> similarYou;    // 与你相似

    public static ReportVo init(Report report, List<DimensionsVo> dimensionsVos, List<SimilarYouVo> similarYouVos) {
        ReportVo vo = new ReportVo();
        BeanUtils.copyProperties(report, vo);

        for (DimensionsVo dimensionsVo : dimensionsVos) {
            DimensionsVo dimensions = new DimensionsVo();
            if(dimensionsVo != null){
                dimensions.setKey(dimensionsVo.getKey());
                dimensions.setValue(dimensionsVo.getValue());
            }
        }

        for (SimilarYouVo similarYouVo : similarYouVos) {
            SimilarYouVo similarYou = new SimilarYouVo();
            if(similarYou != null){
                similarYou.setId(similarYouVo.getId());
                similarYou.setAvatar(similarYouVo.getAvatar());
            }
        }

        vo.dimensions = dimensionsVos;
        vo.similarYou = similarYouVos;
        return vo;
    }

}
